//
//  JOStatusFrame.m
//  新浪微博模拟
//
//  Created by song on 15/7/19.
//  Copyright (c) 2015年 song. All rights reserved.
//
#import <Foundation/Foundation.h>
#include <UIKit/UIKit.h>
#import "JOStatusFrame.h"
#import "JOStatus.h"
#import "JOUser.h"
#define JOStatusCellBorder 5

#define  JOStatusNameFont [UIFont systemFontOfSize:15]

@implementation JOStatusFrame


-(void)setStatus:(JOStatus *)status
{
    _status =status;
    
    
    CGFloat cellW = [UIScreen mainScreen].bounds.size.width;
    
    CGFloat topviewW = cellW;
    CGFloat topviewX = 0;
    CGFloat topviewY =0;
    
    CGFloat iconViewWH = 35;
    CGFloat iconViewX =JOStatusCellBorder;
    CGFloat iconViewY =JOStatusCellBorder;
    
    _iconviewF = CGRectMake(iconViewX, iconViewY, iconViewWH, iconViewWH);

    
    CGFloat nameLabelX = CGRectGetMaxX(_iconviewF)+ JOStatusCellBorder;
    CGFloat nameLabelY = iconViewY ;
    CGSize nameLabelSize = [status.user.name sizeWithFont:JOStatusNameFont];
    _nameLableF =(CGRect){{nameLabelX ,nameLabelY} , nameLabelSize};

    if(status.user.verified)
    {
        CGFloat vipViewW = 14;
        CGFloat vipViewH =nameLabelSize.height;
        CGFloat vipViewX =CGRectGetMaxX(_nameLableF)+JOStatusCellBorder;
        CGFloat vipViewY = nameLabelY;
        _vipviewF =CGRectMake(vipViewX, vipViewY, vipViewW, vipViewH);
        
    }
    
    CGFloat timeLabelX = nameLabelX;
    CGFloat timeLabelY = CGRectGetMaxY(_nameLableF) +JOStatusCellBorder ;
    CGSize timeLabelSize = [status.created_at sizeWithFont:JOStatusNameFont];
    _timeLableF =(CGRect){{timeLabelX ,timeLabelY} , timeLabelSize};

    
    CGFloat sourceLabelX = CGRectGetMaxX(_timeLableF) +JOStatusCellBorder;
    CGFloat sourceLabelY = timeLabelY ;
    CGSize sourceLabelSize = [status.source sizeWithFont:JOStatusNameFont];
    _sourceLableF =(CGRect){{sourceLabelX ,sourceLabelY} , sourceLabelSize};
    
    CGFloat  contentLabelX = iconViewX ;
    CGFloat  contentLabelY = CGRectGetMaxY(_timeLableF) ;
    CGFloat contentLabelMaxW =topviewW -2*JOStatusCellBorder;
    CGSize   contentLabelSize = [status.text sizeWithFont:JOStatusNameFont constrainedToSize:CGSizeMake(contentLabelMaxW, MAXFLOAT)];
    _contentLableF =(CGRect){{contentLabelX ,contentLabelY} , contentLabelSize};
    
    CGFloat topViewH = CGRectGetMaxY(_contentLableF) +JOStatusCellBorder;
    _topviewF =CGRectMake(topviewX, topviewY, topviewW, topViewH);
    _cellHeight =topViewH;
    
    
}

@end
